package com.linwen.javase.desgin_pattern.create.clone;

import com.alibaba.fastjson.JSON;

/**
 * @ClassName TeacherTest
 * @Description
 * @Author lin
 * @Date 2022/6/15 上午12:40
 * @Version V1.0
 */
public class TeacherTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Teacher teacher = new Teacher("张老师", 34, new Student("张三", 15));
        String jsonString = JSON.toJSONString(teacher);
        Teacher clone = JSON.parseObject(jsonString, Teacher.class);
        teacher.setName("李老师");
        teacher.setAge(44);
        teacher.getStudent().setName("李四");
        System.out.println(teacher);
        System.out.println(clone);

    }
}
